package com.simpleframe.views.ui;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

import javax.servlet.jsp.JspException;
import javax.servlet.jsp.tagext.SimpleTagSupport;

import org.apache.commons.lang.StringUtils;
import org.dom4j.Document;
import org.dom4j.Element;

import com.simpleframe.core.io.ClassPathResource;
import com.simpleframe.core.io.Resource;
import com.simpleframe.domain.state.StateContext;
import com.simpleframe.exception.SimpleframeException;
import com.simpleframe.util.XmlUtil;

import net.sf.json.JSONObject;

/**
 * 输出状态用的标
 * @author Administrator
 *
 */
public class StateTag extends SimpleTagSupport{
	
	private static Map<String, Map<String, String>> stateConfigs;
	
	/**
	 * 代表所有状态的JSON
	 */
	private String state;
	/**
	 * 状态值
	 */
	private String value;
	
	public void doTag() throws JspException, IOException {
		String html = "<font red=\"red\">未知状态</font>";
		Map<String, String> states = StateContext.getItemsMap(state);
		for (String key : states.keySet()) {
			if(StringUtils.equals(value, key)){
				html = states.get(key);
			}
		}
		
		//输出页面
		getJspContext().getOut().print(html);
	}
	
	public void setState(String state) {
		this.state = state;
	}
	
	public void setValue(String value) {
		this.value = value;
	}
}
